package cn.uniqueinfo.dp.controller;

import cn.uniqueinfo.dp.annotation.NoRepeatSubmit;
import cn.uniqueinfo.dp.service.IMenuService;
import cn.uniqueinfo.dp.util.TreeMenuUtil;
import cn.uniqueinfo.dp.vo.MenuVO;
import cn.uniqueinfo.dp.vo.UserVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * @author:朱元勋
 * @mail:395910063@qq.com
 * @date:2019-01-03 16:36:31
 * @description:
 */
@Api(tags = "主页面")
@Slf4j
@Controller
@RequestMapping(value = "/main")
public class MainController {

    @ApiOperation(value = "页面入口", notes = "默认的")
    @GetMapping(value = {"/", "/index"})
    @NoRepeatSubmit(value = "防止重复提交测试")
    @RequiresPermissions(value = "main:index")
    public ModelAndView index() {
        // 获取当前登录人信息
        UserVO user = (UserVO) SecurityUtils.getSubject().getPrincipal();
        HashMap<String, Object> param = new HashMap<>();
        param.put("user", user);
        return new ModelAndView("/main/index", param);
    }
}
